﻿namespace DeltaGroup.WheelOfJeopardy.UI.Controls
{
    using System.Windows;
    using System.Windows.Controls;

    using DeltaGroup.WheelOfJeopardy.GameManager;
    using DeltaGroup.WheelOfJeopardy.UI.ViewModel;

    /// <summary>
    /// Interaction logic for NumericUpDown.xaml
    /// </summary>
    public partial class AdjustableSpinRemaining : UserControl
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="AdjustableSpinRemaining"/> class.
        /// </summary>
        public AdjustableSpinRemaining()
        {
            InitializeComponent();
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// Gets the round.
        /// </summary>
        /// <value>The round.</value>
        private NormalRound Round
        {
            get
            {
                return (DataContext as NormalRoundViewModel).Round;
            }
        }

        #endregion Properties

        #region Methods

        /// <summary>
        /// Handles the Click event of the cmdDown control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void cmdDown_Click(object sender, RoutedEventArgs e)
        {
            if(Round.SpinsRemaining > 1)
                Round.SpinsRemaining--;
        }

        /// <summary>
        /// Handles the Click event of the cmdUp control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void cmdUp_Click(object sender, RoutedEventArgs e)
        {
            Round.SpinsRemaining++;
        }

        #endregion Methods
    }
}